/*
 * Copyright (c) 2002-2003 by OpenSymphony
 * All rights reserved.
 */
package org.jackysoft.service;

import java.util.Collection;

import org.jackysoft.data.ServiceProvider;
import org.jackysoft.entity.OsStep;
import org.jackysoft.entity.OsWorkflowRunner;
import org.jackysoft.entity.WorkflowRunner;

public interface OsWorkflowRunnerService extends ServiceProvider<OsWorkflowRunner> {

	// ~ Methods
	// ////////////////////////////////////////////////////////////////

	public void setRunnerState(long entryId, int state);

	public OsStep createCurrentStep(long entryId, long stepId, int actionId,
			String owner, long startDate, long dueDate, String status,
			long[] previousIds) ;

	public void changeRunnerState(final long id, final int state);

	boolean canModifyRunnerState(final long runnerId, final int newState);

	/**
	 * Persists a new workflow entry that has <b>not been initialized</b>.
	 * 
	 * @param workflowName
	 *            the workflow name that this entry is an instance of
	 * @return a representation of the workflow instance persisted
	 */
	public WorkflowRunner createRunner(String workflowName)
			;

	/**
	 * Returns a list of all current steps for the given workflow instance ID.
	 * 
	 * @param entryId
	 *            The workflow instance id.
	 * @return a List of Steps
	 * @see org.jackysoft.entity.spi.Step
	 */
	public Collection<OsStep> findCurrentSteps(long entryId) ;

	public boolean stepIsStatus(long stepId, String status);

	/**
	 * Pulls up the workflow entry data for the entry ID given.
	 * 
	 * @param entryId
	 *            The workflow instance id.
	 * @return a representation of the workflow instance persisted
	 */
	public WorkflowRunner findRunner(long entryId) ;

	public String findRunneRefname(long id);
	/**
	 * stepID
	 * */
	public OsStep findHistoryStep(long id) ;

	public OsStep findCurrentStep(long id) ;

	/**
	 * Returns a list of all steps that are finished for the given workflow
	 * instance ID.
	 * 
	 * @param entryId
	 *            The workflow instance id.
	 * @return a List of Steps
	 * @see org.jackysoft.entity.spi.Step
	 */
	public Collection<OsStep> findHistorySteps(long entryId)
			;

	/**
	 * Called once when the store is first created.
	 * 
	 * @param props
	 *            properties set in osworkflow.xml
	 */
	public void init() ;	

	/**
	 * Mark the specified step as finished.
	 * 
	 * @param step
	 *            the step to finish.
	 * @param actionId
	 *            The action that caused the step to finish.
	 * @param finishDate
	 *            the date when the step was finished.
	 * @param status
	 *            The status to set the finished step to.
	 * @param caller
	 *            The caller that caused the step to finish.
	 * @return the finished step
	 */
	public void markFinished(long step, int actionId, long finishDate,
			String status, String caller)  ;

	/**
	 * Called when a step is finished and can be moved to workflow history.
	 * 
	 * @param step
	 *            the step to be moved to workflow history
	 */
	public void moveToHistory(long step) ;

	
	/**
     * 
     * 
     * */

	void deleteRunner(long id);

	/**
     * 
     * 
     * */

	void completeRunner(long id);

	/**
	 * 
	 * 把该工作流回退一步
	 * 
	 * @param id
	 *            工作流实例编号
	 * 
	 * */

	void rollbackRunner(long id);

	
	void removeCurrentStep(long step);	
	
}
